import sun.net.www.http.HttpClient;

import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author cn
 * @date 2022年03月26日 16:30
 */
public class Client {
    public static void main(String[] args) {


//        for (int i = 0; i <10 ; i++) {
//            new Thread(new Runnable() {
//                @Override
//                public void run() {
////                    CloseableHttpClient httpClient = HttpClient.createDefault();
//                    CloseableHttpClient
//                    HttpGet httpGet = new HttpGet("http://localhost:8080/test_threadsafe");
//                    System.out.println(Thread.currentThread().getName());
//                    httpGet.setHeader("Thread", Thread.currentThread().getName());
//                    try {
//                        httpClient.excute(httpGet);
//                    } catch (ClientProtocolException e) {
//                        e.printStackTrace();
//                    } catch (IOException e){
//                        e.printStackTrace();
//
//                    }
//                }
//            }).start();
//        a引用变量指向常量池中的"abc"
        String a = "abc";
//        复制一份a指向的内存地址赋值给b,a和b指向同一个内存地址
        String b = a;
//        a引用变量也指向常量池中的"abc"
        String c = "abc";
//        new表示在堆中开辟一块内存空间存放String对象,d指向这个地址,String的成员变量变量value指向常量池中的char[g,a,o,q,i]
        String d = new String("gaoqi");
//        String e = null;
        String e = "";
        String f = new String(e);
        String h = new String("");
        String k = "abc" + c + c + d + e ;

        System.out.println(a == b);
        System.out.println(a == c);
        System.out.println(a == d);
        System.out.println("abcabcabcgaoqi".equals(k));
        System.out.println(e == f);
        System.out.println(e.equals(f));
        System.out.println(e.equals(h));

        String str1 = "Hello World!";
        str1.substring(1,4).concat("cbl").toLowerCase().trim().replace('b', 'a');
        System.out.println(str1);

        char[] charArray = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'};
        String str3 = new String(charArray);

//        StringBuilder 在字符串操作方面是最快的。速度次快的是 StringBuffer ，它比 StringBuilder 慢 2~3 倍。String 的 concat 操作最慢。
        String concatString = "concatString";
        StringBuffer appendBuffer = new StringBuffer("appendBuffer");
        StringBuilder appendBuilder = new StringBuilder("appendBuilder");
        long timerStarted;

        timerStarted = System.currentTimeMillis();
        for (int i = 0; i < 50000; i++) {
            concatString += " another string";
        }
        System.out.println("50000次String concat 操作的时间：" + (System.currentTimeMillis() - timerStarted) + "ms");

        timerStarted = System.currentTimeMillis();
        for (int i = 0; i < 50000; i++) {
            appendBuffer.append(" another string");
        }
        System.out.println("50000次 StringBuffer 的 append 操作时间：" + (System.currentTimeMillis() - timerStarted) + "ms");

        timerStarted = System.currentTimeMillis();
        for (int i = 0; i < 50000; i++) {
            appendBuilder.append(" another string");
        }
        System.out.println("50000次 StringBuilder 的 append 操作时间：" + (System.currentTimeMillis() - timerStarted) + "ms");




        Thread t1 = new Thread(()->{

        });
        t1.start();

        new Thread(()->{

        });
//        Child child = new Child();
        Student stu1 = new Student();
//       System.out.println(stu1.show() == stu1);
//        System.out.println(Student.view());
//        System.out.println(Student.getInstance());
//        Student.Computer computer = new Computer("联想");
    }
}


//        DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
//        Date date = new Date();
//        System.out.println(dateFormat.format(date));


//        SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        Date d = new Date();
//        long time1 = System.currentTimeMillis();
//        d.setTime(time1);
//        System.out.println(format.format(d));
//        System.out.println(System.currentTimeMillis()+"client");